package ystp.service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ystp.dao.*;
import ystp.model.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class FujianJieguoService {

    @Resource
    FujianJieguoMapper ddMapper;
    @Resource
    FujianotMapper ddFujianotMapper;
    @Resource
    FujiantMapper ddFujiantMapper;
    @Resource
    FujianjsbMapper ddFujianjsbMapper;
    @Autowired
    FujianslMapper fujianslMapper;
    @Autowired
    FujianwMapper fujianwMapper;
    @Autowired
    FujianqMapper fujianqMapper;
    @Autowired
    FujianbMapper fujianbMapper;
    @Autowired
    FujianjsMapper fujianjsMapper;
    @Autowired
    FujianyuanyanMapper fujianyuanyanMapper;
    @Autowired
    FujianshiliuMapper fujianshiliuMapper;
    @Autowired
    FujiankjjibenMapper fujiankjjibenMapper;
    @Autowired
    FujiankjyuecaiMapper fujiankjyuecaiMapper;
    @Autowired
    FujiantihuanMapper fujiantihuanMapper;

    public List<Map<String, Object>> findBeizhu1(String ppxiangmuId){
        return fujianjsMapper.findBeizhu1(ppxiangmuId);
    }
    public List<Map<String, Object>> findPinguiAll(String ppxiangmuleixing,String ppxiangmuId,String ppDrugname,
                                                  int ppPageIndex, int ppPageSize){
        int mmStartIndex = (ppPageIndex - 1) * ppPageSize;
        if("21".equals(ppxiangmuleixing)){
            return ddFujianotMapper.findPinguiAll(ppxiangmuId,ppDrugname,mmStartIndex,ppPageSize);
        }
        if("22".equals(ppxiangmuleixing)){
            return ddFujianotMapper.findPinguiAll(ppxiangmuId,ppDrugname,mmStartIndex,ppPageSize);
        }
        if("23".equals(ppxiangmuleixing)){
            return ddFujiantMapper.findPinguiAll(ppxiangmuId,ppDrugname,mmStartIndex,ppPageSize);
        }
        if("24".equals(ppxiangmuleixing)){
            return fujianslMapper.findPinguiAll(ppxiangmuId,ppDrugname,mmStartIndex,ppPageSize);
        }
        if("25".equals(ppxiangmuleixing)){
            return fujianwMapper.findPinguiAll(ppxiangmuId,ppDrugname,mmStartIndex,ppPageSize);
        }
        if("26".equals(ppxiangmuleixing)){
            return fujianqMapper.findPinguiAll(ppxiangmuId,ppDrugname,mmStartIndex,ppPageSize);
        }
        if("27".equals(ppxiangmuleixing)){
            return fujianbMapper.findPinguiAll(ppxiangmuId,ppDrugname,mmStartIndex,ppPageSize);
        }
        if("28".equals(ppxiangmuleixing)||"29".equals(ppxiangmuleixing)){
            return fujianjsMapper.findPinguiAll(ppxiangmuId,ppDrugname,mmStartIndex,ppPageSize);
        }
        if("30".equals(ppxiangmuleixing)){
            return fujiantihuanMapper.findPinguiAll(ppxiangmuId,ppDrugname,mmStartIndex,ppPageSize);
        }
        if("31".equals(ppxiangmuleixing)){
            return fujianyuanyanMapper.findPinguiAll(ppxiangmuId,ppDrugname,mmStartIndex,ppPageSize);
        }
        if("32".equals(ppxiangmuleixing)){
            return fujianshiliuMapper.findPinguiAll(ppxiangmuId,ppDrugname,mmStartIndex,ppPageSize);
        }
        if("33".equals(ppxiangmuleixing)||"36".equals(ppxiangmuleixing)){
            return fujiankjjibenMapper.findPinguiAll(ppxiangmuId,ppDrugname,mmStartIndex,ppPageSize);
        }
        if("34".equals(ppxiangmuleixing)){
            return fujiankjyuecaiMapper.findPinguiAll(ppxiangmuId,ppDrugname,mmStartIndex,ppPageSize);
        }
        return null;
    }
    public List<Map<String, Object>> findShengchanqiyeByPinguiResult(String ppxiangmuleixing,String ppxiangmuId,String mmPinguiOne,String ppUserId){
        if("21".equals(ppxiangmuleixing)){
            return ddFujianotMapper.findShengchanqiyeByPinguiResult(ppxiangmuId,mmPinguiOne,ppUserId);
        }
        if("22".equals(ppxiangmuleixing)){
            return ddFujianotMapper.findShengchanqiyeByPinguiResult(ppxiangmuId,mmPinguiOne,ppUserId);
        }
        if("23".equals(ppxiangmuleixing)){
            return ddFujiantMapper.findShengchanqiyeByPinguiResult(ppxiangmuId,mmPinguiOne,ppUserId);
        }
        if("24".equals(ppxiangmuleixing)){
            return fujianslMapper.findShengchanqiyeByPinguiResult(ppxiangmuId,mmPinguiOne,ppUserId);
        }
        if("25".equals(ppxiangmuleixing)){
            return fujianwMapper.findShengchanqiyeByPinguiResult(ppxiangmuId,mmPinguiOne,ppUserId);
        }
        if("26".equals(ppxiangmuleixing)){
            return fujianqMapper.findShengchanqiyeByPinguiResult(ppxiangmuId,mmPinguiOne,ppUserId);
        }
        if("27".equals(ppxiangmuleixing)){
            return fujianbMapper.findShengchanqiyeByPinguiResult(ppxiangmuId,mmPinguiOne,ppUserId);
        }
        if("28".equals(ppxiangmuleixing)||"29".equals(ppxiangmuleixing)){
            return fujianjsMapper.findShengchanqiyeByPinguiResult(ppxiangmuId,mmPinguiOne,ppUserId);
        }
        if("30".equals(ppxiangmuleixing)){
            return fujiantihuanMapper.findShengchanqiyeByPinguiResult(ppxiangmuId,mmPinguiOne,ppUserId);
        }
        if("31".equals(ppxiangmuleixing)){
            return fujianyuanyanMapper.findShengchanqiyeByPinguiResult(ppxiangmuId,mmPinguiOne,ppUserId);
        }
        if("32".equals(ppxiangmuleixing)){
            return fujianshiliuMapper.findShengchanqiyeByPinguiResult(ppxiangmuId,mmPinguiOne,ppUserId);
        }
        if("33".equals(ppxiangmuleixing)||"36".equals(ppxiangmuleixing)){
            return fujiankjjibenMapper.findShengchanqiyeByPinguiResult(ppxiangmuId,mmPinguiOne,ppUserId);
        }
        if("34".equals(ppxiangmuleixing)){
            return fujiankjyuecaiMapper.findShengchanqiyeByPinguiResult(ppxiangmuId,mmPinguiOne,ppUserId);
        }
        return null;
    }
    public Integer getPinguiCount(String ppxiangmuleixing,String ppxiangmuId,int ppPageIndex, int ppPageSize) {
        Object mmCount=null;
        if("21".equals(ppxiangmuleixing)){
            mmCount = ddFujianotMapper.getPinguiCount(ppxiangmuId,ppPageIndex,ppPageSize);
        }
        if("22".equals(ppxiangmuleixing)){
            mmCount = ddFujianotMapper.getPinguiCount(ppxiangmuId,ppPageIndex,ppPageSize);
        }
        if("23".equals(ppxiangmuleixing)){
            mmCount = ddFujiantMapper.getPinguiCount(ppxiangmuId,ppPageIndex,ppPageSize);
        }
        if("24".equals(ppxiangmuleixing)){
            mmCount = fujianslMapper.getPinguiCount(ppxiangmuId,ppPageIndex,ppPageSize);
        }
        if("25".equals(ppxiangmuleixing)){
            mmCount = fujianwMapper.getPinguiCount(ppxiangmuId,ppPageIndex,ppPageSize);
        }
        if("26".equals(ppxiangmuleixing)){
            mmCount = fujianqMapper.getPinguiCount(ppxiangmuId,ppPageIndex,ppPageSize);
        }
        if("27".equals(ppxiangmuleixing)){
            mmCount = fujianbMapper.getPinguiCount(ppxiangmuId,ppPageIndex,ppPageSize);
        }
        if("28".equals(ppxiangmuleixing)||"29".equals(ppxiangmuleixing)){
            mmCount = fujianjsMapper.getPinguiCount(ppxiangmuId,ppPageIndex,ppPageSize);
        }
        if("30".equals(ppxiangmuleixing)){
            mmCount = fujiantihuanMapper.getPinguiCount(ppxiangmuId,ppPageIndex,ppPageSize);
        }
        if("31".equals(ppxiangmuleixing)){
            mmCount = fujianyuanyanMapper.getPinguiCount(ppxiangmuId,ppPageIndex,ppPageSize);
        }
        if("32".equals(ppxiangmuleixing)){
            mmCount = fujianshiliuMapper.getPinguiCount(ppxiangmuId,ppPageIndex,ppPageSize);
        }
        if("33".equals(ppxiangmuleixing)||"36".equals(ppxiangmuleixing)){
            mmCount = fujiankjjibenMapper.getPinguiCount(ppxiangmuId,ppPageIndex,ppPageSize);
        }
        if("34".equals(ppxiangmuleixing)){
            mmCount = fujiankjyuecaiMapper.getPinguiCount(ppxiangmuId,ppPageIndex,ppPageSize);
        }
        return mmCount == null ? 0 : Integer.parseInt(mmCount.toString());
    }
    public int countPass(String ppxiangmuleixing,String ppXiangmuId,String ppUserId){
        Object mmCount=null;
        if("21".equals(ppxiangmuleixing)){
             mmCount = ddFujianotMapper.countPass(ppXiangmuId,ppUserId);
        }
        if("22".equals(ppxiangmuleixing)){
            mmCount = ddFujianotMapper.countPass(ppXiangmuId,ppUserId);
        }
        if("23".equals(ppxiangmuleixing)){
            mmCount = ddFujiantMapper.countPass(ppXiangmuId,ppUserId);
        }
        if("24".equals(ppxiangmuleixing)){
            mmCount = fujianslMapper.countPass(ppXiangmuId,ppUserId);
        }
        if("25".equals(ppxiangmuleixing)){
            mmCount = fujianwMapper.countPass(ppXiangmuId,ppUserId);
        }
        if("26".equals(ppxiangmuleixing)){
            mmCount = fujianqMapper.countPass(ppXiangmuId,ppUserId);
        }
        if("27".equals(ppxiangmuleixing)){
            mmCount = fujianbMapper.countPass(ppXiangmuId,ppUserId);
        }
        if("28".equals(ppxiangmuleixing)||"29".equals(ppxiangmuleixing)){
            mmCount = fujianjsMapper.countPass(ppXiangmuId,ppUserId);
        }
        if("30".equals(ppxiangmuleixing)){
            mmCount = fujiantihuanMapper.countPass(ppXiangmuId,ppUserId);
        }
        if("30".equals(ppxiangmuleixing)){
            mmCount = fujiantihuanMapper.countPass(ppXiangmuId,ppUserId);
        }
        if("31".equals(ppxiangmuleixing)){
            mmCount = fujianyuanyanMapper.countPass(ppXiangmuId,ppUserId);
        }
        if("32".equals(ppxiangmuleixing)){
            mmCount = fujianshiliuMapper.countPass(ppXiangmuId,ppUserId);
        }
        if("33".equals(ppxiangmuleixing)||"36".equals(ppxiangmuleixing)){
            mmCount = fujiankjjibenMapper.countPass(ppXiangmuId,ppUserId);
        }
        if("34".equals(ppxiangmuleixing)){
            mmCount = fujiankjyuecaiMapper.countPass(ppXiangmuId,ppUserId);
        }
        return mmCount == null ? 0 : Integer.parseInt(mmCount.toString());
    }
    public Fujianot findOne(FujianotKey key){
        return ddFujianotMapper.selectByPrimaryKey(key);
    }
    public FujianJieguo checkexistByUserId(String ppId, String ppUserId,String ppxiangmuid){
        FujianJieguoExample mmExample=new FujianJieguoExample();
        mmExample.createCriteria().andDetailidEqualTo(ppId).andUseridEqualTo(ppUserId).andXiangmuidEqualTo(ppxiangmuid);
        return ddMapper.selectByExample(mmExample).size()>0? ddMapper.selectByExample(mmExample).get(0): null;
    }
    public Integer checkCountByPinguiandUserId(String ppPinguixuhao, String ppUserId,String ppxiangmuid){
        FujianJieguoExample mmExample=new FujianJieguoExample();
        mmExample.createCriteria().andXuhaoEqualTo(ppPinguixuhao).andUseridEqualTo(ppUserId).andXiangmuidEqualTo(ppxiangmuid).andResultEqualTo("1");
        Object mmCount=ddMapper.selectByExample(mmExample).size();
        return mmCount == null ? 0 : Integer.parseInt(mmCount.toString());
    }
    public boolean modify(FujianJieguo ppFujianJieguo){
        return ddMapper.updateByPrimaryKeySelective(ppFujianJieguo)==1;
    }
    public boolean add(FujianJieguo ppFujianJieguo){
        return ddMapper.insert(ppFujianJieguo)==1;
    }
    public int countPingguiPass(String ppxiangmuId,String ppPingui,String ppUserId){
        FujianJieguoExample mmExample=new FujianJieguoExample();
        mmExample.createCriteria().andXiangmuidEqualTo(ppxiangmuId).andXuhaoEqualTo(ppPingui).andUseridEqualTo(ppUserId).andResultEqualTo("1");
        return ddMapper.countByExample(mmExample);
    }

}
